package 算法回顾;

/**
 * @author : K k
 * @date : 21:48 2020/8/25
 */
public class Swap_Sort {

    public static void main(String[] args) {
        int[] a={49,38,65,97,76,13,27,49,78,34,12,64,1,8};
        sort(a);

        int b=16>>1;
        System.out.println(b);
        //sortB(a);
    }

    public static void sort(int[] a){
        if(a==null||a.length==0){
            return;
        }
        System.out.println("排序之前：");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]+" ");
        }

        for (int i=0;i<a.length; i++){
            for (int j=0; j<a.length-i-1;j++){
                if (a[j]>a[j+1] ){
                    int temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
        System.out.println();
        System.out.println("排序之后：");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]+" ");
        }

    }
}
